package com.text.textRecognition.service;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.UUID;

@Service
public class PayService {

    @Value("${alipay.returnUrl}")
    private String returnUrl;

    public Object pay(Integer unit, Integer number) throws Exception {

        BigDecimal decimal = new BigDecimal(unit * number);
        AlipayTradePagePayResponse response = Factory.Payment.Page().pay(
                "打印订单",
                UUID.randomUUID().toString().substring(0, 10),
                decimal.toString(),
                returnUrl);
        return response.body;
    }
}
